package com.authsphere.security.account.api.bind;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * @program: AuthSphere
 * @description:
 * @author: YuKai Fan
 * @create: 2025/3/22 20:56
 **/
public class InMemoryAccountBindTempTokenRepository implements AccountBindTempTokenRepository {
    private final static Map<String, TempBindToken> TEMP_BIND_TOKEN_MAP = Maps.newConcurrentMap();

    @Override
    public void createNewToken(TempBindToken token) {
        TEMP_BIND_TOKEN_MAP.put(token.getTokenValue(), token);
    }

    @Override
    public TempBindToken getTokenForValue(String tokenValue) {
        return TEMP_BIND_TOKEN_MAP.get(tokenValue);
    }

    @Override
    public void removeToken(String tokenValue) {
        TEMP_BIND_TOKEN_MAP.remove(tokenValue);
    }
}
